//
// Created by qiangqiangj on 2019/10/30.
//
#include <string.h>

void reverse_str(const char *source, char target[], unsigned int length) {
    unsigned int i;
    for (i = 0; i < length; i++)
        target[i] = source[length - 1 - i];
    target[i] = 0;
}

extern const char *to_hex(unsigned int num, char *hexStr) {
    unsigned int len = num;
    char hex_table[] = "0123456789ABCDEF";
    char temp_hex[16], hex[16];
    unsigned int i = 0;
    while (len) {
        temp_hex[i++] = hex_table[num];
        num /= 16;
    }
    temp_hex[i] = 0;
    reverse_str(temp_hex, hex, i);
    strcpy(hexStr,hex);
}

